<%- include('header')%>

    <div class="main">
        <div class="container">
            <form class="reply comment__form" method="post" action="/comments">
                <input name="postId" value="<%= post._id %>" hidden />
                <h1 class="text-primary">
                    <a href="/post/<%= post._id?.toString()%>">
                        <%= post.title%>
                    </a>
                </h1>
                <div class="main-middle">
                    <div class="middle-top">
                        <div>
                            <a class="avatar avatar-link" href="/user/<%= post.authorId?.toString() %>">
                                <img class="avatar" src="<%= post.author.avatar || '/img/avatar.png' %>">
                            </a>
                            <div>
                                <h4> <a href="/user/<%= post.authorId?.toString() %>">
                                        <%= post.author.username %>
                                    </a>
                                </h4>
                                <p>
                                    发表于 <%= post.created %>
                                        <span>浏览(<%= post.pv %>)</span>
                                        <span>留言(<%= post.commentCount %>)</span>
                                </p>
                            </div>
                        </div>
                        <div class="right">
                            <%if(authUser && authUser._id.toString()===post.authorId.toString()){%>
                                <div class="item">
                                    <a href="/post/<%= post._id?.toString()%>/edit" title="编辑当前文章"><i
                                            class="glyphicon glyphicon-edit text-info"></i></a>
                                </div>
                                <div class="item">
                                    <a href="/post/<%= post._id?.toString()%>/delete" title="删除当前文章"
                                        class="delete delete-post"><i
                                            class="glyphicon glyphicon-trash text-danger"></i></a>

                                </div>
                                <%}%>
                        </div>
                    </div>
                    <div class="middle-img">
                        <img src="<%= post.img%>" alt="">
                    </div>
                    <div class="middle-bottom">
                        <p>
                            <%- post.content%>
                        </p>
                        <textarea class="form-control" rows="5" placeholder="写下你的评论"></textarea>
                        <a href="#" class="btn btn-primary btn-lg " role="button">发表评论</a>
                    </div>
                </div>
            </form>
            <div class="main-bottom">
                <h3>全部评论</h3>
                <div class="comment">
                    <div class="comment-content">
                        <% if(!comments || comments.length < 1) {%>
                            <p class="text-align-center mt-50 mb-50 color-999">还没有人发表评论</p>
                            <%} else {%>
                                <% comments.forEach(function (comment) { %>
                                    <img class="img-circle" src="/upload/<%= comment.user.avatar %>" alt="">
                                    <div>
                                        <p>
                                            <a class="author" href="/user/<%= comment.user._id %>">
                                                <%= comment.user.username %>
                                            </a>
                                        </p>
                                        <p><span class="date">
                                                <%= comment.created_at %>
                                            </span></p>
                                        <p>
                                            <%- comment.content %>
                                        </p>
                                    </div>
                                    <a href="/comment/<%= comment._id %>/remove">删除</a>
                                    <% }) %>
                                        <%}%>

                    </div>

                </div>
                <hr>
            </div>
        </div>
    </div>

    <%- include('footer')%>